﻿Public Class ClspdOrdenC

    Inherits ClsSQL

    Dim orden_id As Integer
    Dim periodo As String
    Dim producto_id As String
    Dim FechaInicio As Date
    Dim FechaFin As Date
    Dim FechaCie As Date
    Dim Cliente_id As Integer
    Dim descripcion As String
    Dim impote As Double
    Dim utilidad As Double
    Dim impuesto As Double
    Dim gastos As Double
    Dim moneda_id As Integer
    Dim Lugar_ent As String
    Dim formapago As String
    Dim tipo As Integer
    Dim garantia As Integer
    Dim estado As Integer
    Dim usuario As String
    Dim fechareg As Date
    Dim usuariomodif As String
    Dim fechamodif As Date


#Region "Propiedades"
    Property Porden_id() As Integer
        Get
            Return orden_id
        End Get
        Set(ByVal value As Integer)
            orden_id = value
        End Set
    End Property

    Property Pdescripcion() As String
        Get
            Return descripcion
        End Get
        Set(ByVal value As String)
            descripcion = value
        End Set
    End Property

    Property Ptipo() As Integer
        Get
            Return tipo
        End Get
        Set(ByVal value As Integer)
            tipo = value
        End Set
    End Property

    Property Pgarantia() As Integer
        Get
            Return garantia
        End Get
        Set(ByVal value As Integer)
            garantia = value
        End Set
    End Property
    Property Pestado() As String
        Get
            Return estado
        End Get
        Set(ByVal value As String)
            estado = value
        End Set
    End Property
#End Region

#Region "Procedmientos y Funciones"
    Public Function Insertar()
        Dim sql As String
        'sql = "INSERT INTO MOVIMIENTO VALUES ('" & Pfecha.Date.ToString("yyyyMMdd") & "','" & Pidalmacen & "','" & Pidlugar & "','" & Pidherramienta & "','" & Pcantidad & "', '" & Pidtipomovimiento & "', '" & Pidmovimiento & "','" & Pestado() & "')"
        Return (Me.Ejecutar(sql))
    End Function
    Public Function Modificar()
        Dim sql As String
        'sql = "UPDATE MOVIMIENTO SET IDTIPOMOVIMIENTO=5 WHERE IDTIPOMOVIMIENTO='" & Pidtipomovimiento() & "' AND IDMOVIMIENTO='" & Pidmovimiento() & "' "
        Return (Me.Ejecutar(sql))
    End Function
    Public Function Eliminar()
        Dim sql As String
        'sql = "UPDATE MOVIMIENTO SET IDTIPOMOVIMIENTO=6 WHERE IDTIPOMOVIMIENTO='" & Pidtipomovimiento() & "' AND IDMOVIMIENTO='" & Pidmovimiento() & "' "
        Return (Me.Ejecutar(Sql))
    End Function

    Sub ClsConectar(ByVal bd As String, Optional ByVal servidor As String = "")
        Select Case bd
            Case "administracion"
                Conectar(0)
            Case "corbol"
                Conectar(1)
            Case "importacion"
                Conectar(2)
            Case "corbol09"
                Conectar(3)
            Case "corbol2010"
                Conectar(4)
            Case "pruebas"
                Conectar(5)
            Case "corbol2011"
                Conectar(6)
        End Select
    End Sub
    Sub ClsDesConectar()
        Desconectar()
    End Sub

    Function ClsTraerDataTable(ByVal opcion As Int16, Optional ByVal filtro As String = "") As DataTable
        Select Case opcion
            Case 0
                Return TraerTabla("VpdOrdenC", "TOP 200 *", "1=1 ORDER BY ORDEN_ID DESC")
            Case 1
                Return Buscador("VpdOrdenC", filtro)
            Case 2
                Return Buscador("VpdOrdenC", "WHERE Orden_id=" & Porden_id() & " ")
            Case 3
                Return TraerTabla("VpdOrdenC", " * ", filtro)
            Case 4
                Return TraerTabla("VpdOrdenCS", " * ", filtro)
            Case 5
                'este creo que ya no va servir
                Return TraerTabla("VpdOrdenCSA", "*")
            Case 6
                Return TraerTabla("VpdAvanceOT", " * ", filtro)
        End Select
    End Function
    Function ClsTraerDataSet(Optional ByVal opcion As Integer = 0) As DataSet
        'Select Case opcion
        '    Case 0
        '        Return TraerTablaDs("VALMACEN", "*")
        '        'Case 1
        '        '    Return BuscadorDs("VAUTOPORCLIENTE", "WHERE CLIENTE=" & Pidcliente() & " ")
        'End Select
    End Function
#End Region

End Class
